/*
 * Copyright (c) 2024. Shanghai HEADING information Engineering Co., Ltd. All rights reserved.
 */
package com.lovely602.design.study.basic;

import java.io.File;
import java.io.IOException;

/**
 * @author lizhixing
 */
public class FileTest {

  public static void main(String[] args) throws IOException {
    File file = new File("D:\\test.png");

    boolean exists = file.exists();
    System.out.println("文件是否存在: " + exists);
    String fileName = file.getName();
    System.out.println("文件名: " + fileName);
    String fileParent = file.getParent();
    System.out.println("文件目录: " + fileParent);
    String absolutePath = file.getAbsolutePath();
    System.out.println("绝对路径: " + absolutePath);
    long length = file.length();
    System.out.println("文件大小: " + length);
    long lastModified = file.lastModified();
    System.out.println("文件最后修改时间: " + lastModified);
    boolean canRead = file.canRead();
    System.out.println("文件是否可读: " + canRead);
    boolean canWrite = file.canWrite();
    System.out.println("文件是否可写: " + canWrite);
    boolean canExecute = file.canExecute();
    System.out.println("文件是否可执行: " + canExecute);
    boolean directory = file.isDirectory();
    System.out.println("是否是目录: " + directory);
    boolean fileFile = file.isFile();
    System.out.println("是否是文件: " + fileFile);

  }

}
